import { instance } from '../request'

const request = instance

/**
 *分页获取系统信息列表
 * @param page
 * @param size
 * @param systemCode
 * @returns
 */
export const getSystemInfoListApi = (
  page: number,
  size: number,
  systemCode?: string
): PromiseRes<QuerySystemInfoListItf> =>
  request.get(
    `/systemInfo/systemInfoList?systemCode=${systemCode}&size=${size}&page=${page}`
  )

/**
 * 创建系统信息或者修改系统信息
 * @param systemInfo 系统信息
 * @returns
 */
export const setSystemInfoApi = (systemInfo: {
  systemIP: string
  systemCode: string
  id?: string
  remark?: string
}): PromiseRes => request.post(`/systemInfo/setSystemInfo`, systemInfo)

/**
 * 批量删除系统信息
 * @param systemInfoIdList 系统信息id列表
 * @returns
 */
export const deleteSystemInfoApi = (systemInfoIdList: string[]): PromiseRes =>
  request.post('/systemInfo/deleteSystemInfo', systemInfoIdList)

/**
 * 批量更新系统信息状态
 * @param systemInfoIdList 系统信息id列表
 * @param status 状态 0启用，1禁用
 * @returns
 */
export const updateSystemInfoStatusAPi = (
  systemInfoIdList: string[],
  status: 0 | 1
): PromiseRes =>
  request.post(
    `/systemInfo/updateSystemInfoStatus?status=${status}`,
    systemInfoIdList
  )
